package com.googlecode.yoohoo.xmppcore.protocol.stanza;

import junit.framework.Assert;

import org.junit.Test;

import com.googlecode.yoohoo.xmppcore.protocol.JabberId;
import com.googlecode.yoohoo.xmppcore.protocol.translation.ITranslator;

public class IqTest {
	@Test
	public void toXml() {
		String xml =
			"<iq type='get' id='s2c1' from='capulet.lit' to='juliet@capulet.lit/balcony'>" +
				"<ping xmlns='urn:xmpp:ping'/>" +
			"</iq>";

		Iq iq = new Iq();
		iq.setFrom(new JabberId("capulet.lit"));
		iq.setTo(new JabberId("juliet", "capulet.lit", "balcony"));
		iq.setId("s2c1");
		iq.setType("get");
		
		iq.setObject(new ITranslator() {

			@Override
			public String toXml() {
				return "<ping xmlns='urn:xmpp:ping'/>";
			}
			
		});
		
		Assert.assertEquals(xml, iq.toXml());
	}
}
